﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.EntityModel;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.Core.Locations
{
    [Serializable]
    public class Address : ValueObject<Address>
    {
        #region Fields

        private readonly string _city;
        private readonly string _street;
        private readonly int _zipCode;
        private readonly int? _houseNumber;
        private readonly int? _apartmentNumber;
        private readonly int? _pOBox;
        private readonly string _entrance;

        #endregion

        #region Constructors

        private Address()
        {
        }

        public Address(string city, string street, int zipCode, int? houseNumber,
            int? apartmentNumber, int? poBox, string entrance)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(city), "city could not be null or empty.");

            _city = city;
            _street = street;
            _zipCode = zipCode;
            _houseNumber = houseNumber;
            _apartmentNumber = apartmentNumber;
            _pOBox = poBox;
            _entrance = entrance;
        }

        #endregion

        #region Properties

        public virtual string City
        {
            get { return _city; }
        }

        public virtual string Street
        {
            get { return _street; }
        }

        public virtual int ZipCode
        {
            get { return _zipCode; }
        }

        public virtual int? HouseNumber
        {
            get { return _houseNumber; }
        }

        public virtual int? ApartmentNumber
        {
            get { return _apartmentNumber; }
        }

        public virtual int? POBox
        {
            get { return _pOBox; }
        }

        public virtual string Entrance
        {
            get { return _entrance; }
        }

        #endregion

        #region Object Overrides

        public override string ToString()
        {
            return string.Format("Address: {0} #&# {1} #&# {2} #&# {3} #&# {4} #&# {5} #&# {6} #&#",
                City, Street, ZipCode, HouseNumber, ApartmentNumber, POBox, Entrance);
        }

        #endregion
    }
}
